package com.quyunshuo.module.home.room.dao

import androidx.room.Dao
import androidx.room.Query
import com.quyunshuo.module.home.room.entity.Steps
import kotlinx.coroutines.flow.Flow
import java.util.Date

@Dao
interface StepsDao : BaseDao<Steps> {

    @Query("SELECT * FROM steps ORDER BY date DESC")
    fun queryAll(): Flow<List<Steps>>


    @Query("SELECT * FROM steps ORDER BY date DESC limit :count")
    fun queryLimitCount(count: Int): Flow<List<Steps>>


    @Query("SELECT * FROM steps ORDER BY date DESC LIMIT 1")
    fun getLatestSteps(): Flow<Steps?>


    @Query("SELECT * FROM steps where date = :date")
    fun queryTodayStepF(date: Date): Flow<Steps?>


    @Query("SELECT * FROM steps where date = :date")
    suspend fun queryTodayStep(date: Date): Steps?

    @Query("SELECT * FROM steps WHERE date BETWEEN :startTime AND :endTime ORDER BY date ASC")
    suspend fun getStepsBetween(startTime: Long, endTime: Long): List<Steps>

}